<?php
namespace app\shop\model;
use think\Db;
use think\Model;

class Order extends Model
{
    protected $table = 'slzd_sh_order';

    // 查看订单详情
    public function getOrderData()
    {
        $data = $this->table('slzd_rrb_list')->where('status',1)->select();
        return $data;
    }
    //获取提交的购物车数据
    public function getPushCartData($car_ids){
        $res = Db::name('sh_cart a')
        ->field('a.*,is_on_sale')
        ->join('slzd_sh_goods b', 'a.goods_id = b.goods_id')
        ->where('is_on_sale',1)
        ->where('id','in',$car_ids)->select();
        if($res){
            return $res;
        }
        return false;
    }
    //添加该订单的商品
    public function addOrderGoods($data,$orderid){
        $data['order_id'] = $orderid;
        unset($data['id']);
        unset($data['user_id']);
        unset($data['selected']);
        unset($data['add_time']);
        unset($data['promotional_price']);
        unset($data['is_on_sale']);
        unset($data['session_id']);
        Db::name('sh_order_goods')->save($data);
        return true;
    }
}